package cn.webrx;

import org.apache.shiro.realm.Realm;
import org.apache.shiro.realm.text.TextConfigurationRealm;
import org.apache.shiro.spring.config.ShiroAnnotationProcessorConfiguration;
import org.apache.shiro.spring.config.ShiroBeanConfiguration;
import org.apache.shiro.spring.config.ShiroConfiguration;
import org.springframework.context.annotation.*;

/**
 * <p>功能描述: </p>
 *
 * @author webrx
 * @version 1.0
 * @date 2020-06-11 16:11
 */
@Configuration
@Import({ShiroBeanConfiguration.class, ShiroConfiguration.class, ShiroAnnotationProcessorConfiguration.class})
@ComponentScan("cn.webrx")
public class CliApp {
    @Bean
    public Realm realm() {
        TextConfigurationRealm realm = new TextConfigurationRealm();
        realm.setUserDefinitions("wangwu=123,user\nlisi=123456,admin");
        realm.setRoleDefinitions("admin=read,write\nuser=read");
        realm.setCachingEnabled(true);
        return realm;
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(CliApp.class);
        context.getBean(QuickStart.class).run();
        System.exit(0);
    }
}